
package com.skcc.cop.mrtaxi.biz;


import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.skcc.cop.mrtaxi.BaseActivity;
import com.skcc.cop.mrtaxi.R;


public class LoginActivity extends BaseActivity {
	
	private Button mRegisterButton;
	private Button mLoginButton;
	
	private EditText mEmailEdittext;
	private EditText mPasswordEdittext;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
		
		mEmailEdittext = (EditText) this.findViewById(R.id.login_email_edittext);
		mPasswordEdittext = (EditText) this.findViewById(R.id.login_password_edittext);
		
		mRegisterButton = (Button) this.findViewById(R.id.login_register_button);
		mLoginButton = (Button) this.findViewById(R.id.login_login_button);
		
		mRegisterButton.setOnClickListener(clickListener);
		mLoginButton.setOnClickListener(clickListener);
		
	}
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

		@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}

	private OnClickListener clickListener = new OnClickListener() {

		@Override
		public void onClick(View v) {
			switch (v.getId())
			{
				case R.id.login_register_button:
					Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
					startActivity(intent);
					break;
					
				case R.id.login_login_button:
					login();
					break;
			}
			
			return;
			
		}
		
	};

	
	protected void login() {
		showProgressDialog(this, R.string.loading);
		
		String email = mEmailEdittext.getText().toString().trim();
		String password = mPasswordEdittext.getText().toString().trim();
//		gateway.login(email, password, new LoginListener() {
//
//			@Override
//			public void onNoNetwork() {
//				dismissProgressDialog();
//				
//				// show dialog
//			}
//
//			@Override
//			public void onNoResponse() {
//				dismissProgressDialog();
//				
//				// show dialog
//			}
//
//			@Override
//			public void onSessionTimeOut() {
//				dismissProgressDialog();
//				
//				// show dialog
//			}
//
//			@Override
//			public void onSuccess() {
//				dismissProgressDialog();
//				
//				// 로그인 화면은 기사 평가 남기기, history 남기기 기능 때 보여준다.
////				Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
////				startActivity(intent);
////				finish();
//			}
//
//			@Override
//			public void onFail(int code, String msg) {
//				dismissProgressDialog();
//				
//				// show dialog
//			}
//			
//		});
	}
	
	
	
//	@Override
//	public boolean onCreateOptionsMenu(Menu menu) {
//		// Inflate the menu; this adds items to the action bar if it is present.
//		getMenuInflater().inflate(R.menu.login, menu);
//		return true;
//	}
}
